<?php

/**
 * 用用户提供的回调函数做索引检查来计算数组的差集
 */

function key_compare_func($a, $b)
{
	//if ($a === $b) return 0;
	//return ($a > $b) ? 1 : -1;
	
	if ($a === $b) return 0;
	return 1;
}

$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
$array2 = array("a" => "green", "yellow", "red");
var_dump(array_diff_uassoc($array1, $array2, 'key_compare_func'));